#ifndef __ARRAY_H__
#define __ARRAY_H__

#include "defs.h"

typedef struct ARRAY {
    uint_t data_size, count, capacity ;
    byte_t *data ;
} ARRAY, *array_h ;

/*
    return null if memory allocation failed
*/
array_h array_new(uint_t data_size) ;
void array_delete(array_h *arr) ;

/*
    return 0 if arr is null
*/
uint_t array_size(array_h arr) ;

/*
    if copy_by_val is null, simply increment the side,
    and allocate more memory if necessary.
    
    return a pointer to the newly allocated/last element's 
    memory.
*/
handle_t array_push(array_h arr, const handle_t copy_by_val) ;

void array_remove(array_h arr, handle_t item_to_find) ;
void array_remove_ind(array_h arr, uint_t index) ;

/*
    return null if any kind of error.
    
    Allow user to access 1 past the end of arr.
    (That is to say,
    array_get(array, array->count),
    is valid)
*/
handle_t array_get(array_h arr, uint_t index) ;
 
#endif